 function $(id){
	return document.getElementById(id);
}
	// 账号信息验证
	function checkInpnt(){
		var dengluming=$('dengluxx_2').value;
		if (dengluming=="") {
			$('show_pic').className="no";
			$('show_txt').innerHTML="请输入登录名";
			return false;
		}else if(dengluming.length<4){
			$('show_pic').className="no";
			$('show_txt').innerHTML="请输入4-20位字符";
			return false;
		}else{
			$('show_pic').className="yes";
			$('show_txt').innerHTML="";
			return true;
		}
	}

	function checkPwd(){
		var pwd=$('mimaxx_2').value;
		var shuzi=/^.*[^\d].*$/;	//非纯数字匹配
		var zimu=/^.*[^a-zA-Z].*$/;  //非纯字母匹配
		
		if (pwd==""){
			$('show_pic1').className="no";
			$('show_txt1').innerHTML="请输入密码";
			return false;
		}else if (pwd.length>5){
			console.log(pwd);
			if (shuzi.test(pwd)){	
			 	if (zimu.test(pwd)) {
			 		$('show_pic1').className="yes";
			 		$('show_txt1').innerHTML="";
			 		return true;
			 	}else{
			 		$('show_pic1').className="no";
					$('show_txt1').innerHTML="不能是纯字母";
					return false;
			 	}
			}else{
				$('show_pic1').className="no";
				$('show_txt1').innerHTML="不能是纯数字";
				return false;
			}
		}else{
			$('show_pic1').className="no";
			$('show_txt1').innerHTML="请输入6-20位数字加字母";
			return false;
		}
	}

	function checkPwd2(){
		var pwd=$('mimaxx_2').value;
		var pwd2=$('mimaxx2_2').value;
		if (pwd2==""){
			$('show_pic2').className="no";
			$('show_txt2').innerHTML="请再次输入密码";
			return false;
		}else if (pwd2 != pwd){
			$('show_pic2').className="no";
			$('show_txt2').innerHTML="两次输入密码要一致";
			return false;
		}else if (pwd2 == pwd){
			$('show_pic2').className="yes";
			$('show_txt2').innerHTML="";
			return true;
		}
	}
function checkForm1(){
	if (checkInpnt()&&checkPwd()&&checkPwd2()) {
		$('FormError1').style.display='none';
		return true;
	}else{
		console.log("账号信息出错");
		$('FormError1').style.display='block';
		return false;
	}
}
	// 联系人信息验证
	function checkName(){
		var name=$('namexx_2').value;
		if (name==""){
			$('show_pic3').className="no";
			$('show_txt3').innerHTML="联系人姓名不能为空";
			return false;
		}else{
			$('show_pic3').className="yes";
			$('show_txt3').innerHTML="";
			return true;
		}
	}

	function checkNum(){
		var num=$('numxx_2').value;
		var reg=/^[1]+[34578]+[0-9]/
		if (num=="") {
			$('show_pic4').className="no";
			$('show_txt4').innerHTML="手机号不能为空";
			return false;
		}else if (reg.test(num)&&num.length==11){
			$('show_pic4').className="yes";
			$('show_txt4').innerHTML="";
			return true;
		}else {
			$('show_pic4').className="no";
			$('show_txt4').innerHTML="请输入13/15/17/18的11位数字";
			return false;
		}
	}

	var time=60;
	var Msg;
	function sendMsg(){
		// var arr = new Array('013456789');
		var dxi;
		var yzm="";
		for(var i=0;i<4;i++){
			dxi = Math.floor(Math.random()*10);
			yzm += dxi;
			console.log(yzm+"随机产生的第"+(i+1)+"位验证码");
		}
		times();
		alert("【中国供应商】中国供应商注册验证码：【"+yzm+"】;请您在2分钟能填写。如果非本人操作请忽略！");
		Msg=yzm;
	}

	function times(){
		if (time==0) {
			$("dx_btn").removeAttribute("disabled");
			$("dx_btn").value="获取验证码";
			Msg="";
			time=60;
		}else{
			$("dx_btn").setAttribute("disabled",true);
			$("dx_btn").value="重新发送（"+time+"s)";
			time--;
			setTimeout(times,1000);
		}
	}

	function getMsg(){
		console.log(Msg+"移出时匹配");
		var msg=$('dxxx_2').value;
		var reg=/^.*[^\d].*$/;
		if (msg=="") {
			$('show_pic5').className="no";
			$('show_txt5').innerHTML="短信验证码不能为空";
			return false;
		}else if (msg.length==4){
			if (reg.test(msg)){
				$('show_pic5').className="no";
				$('show_txt5').innerHTML="请输入数字验证码";
				return false;
			}else if (msg==Msg) {
				$('show_pic5').className="yes";
				$('show_txt5').innerHTML="";
				return true;
			}else{
				$('show_pic5').className="no";
				$('show_txt5').innerHTML="验证码不正确";
				return false;
			}
		}else{
			$('show_pic5').className="no";
			$('show_txt5').innerHTML="请输入4位数字";
			return false;
		}
	}

function checkForm2(){
	if (checkName()&&checkNum()&&getMsg()) {
		$('FormError2').style.display='none';
		return true;
	}else{
		console.log("联系人信息出错");
		$('FormError2').style.display='block';
		return false;
	}
}
	

	// 公司信息验证
	function gsname(){ 
		var gsname=$('gsnamexx_2').value;
		var reg=/^[\D+\u4e00-\u9fa5]+$/i
		if (gsname==""){
			$('show_pic6').className="no";
			$('show_txt6').innerHTML="公司名不能为空";
			return false;
		}else{
			if (gsname.indexOf("[\d]")== -1){
				if (reg.test(gsnae)) {
					$('show_pic6').className="yes";
					$('show_txt6').innerHTML="";
					return true;
				}else{
					$('show_pic6').className="no";
					$('show_txt6').innerHTML="不能输入阿拉伯数字";
					return false;
				}
			}else{
				$('show_pic6').className="no";
				$('show_txt6').innerHTML="不能有空格";
				return false;
			}
		}
	}

		function checkIpt(){
			var cp1=$('chanpin1').value;
			var cp2=$('chanpin2').value;
			var cp3=$('chanpin3').value;
			var cp4=$('chanpin4').value;
			if (cp1==""&&cp2==""&&cp3==""&&cp4==""){
				$('show_pic8').className="no";
				$('show_txt8').innerHTML="至少填写一款您主营的产品或服务";
				return false;
			}else{
				if (cp1!=""&&cp2!=""&&cp3!=""&&cp4!=""){
					$('show_pic8').className="yes";
					$('show_txt8').innerHTML="非常好";
					return true;
				}else{
					$('show_pic8').className="yes";
					$('show_txt8').innerHTML="您可以继续填写";
					return true;
				}
			}
		}

	function gsjieshao(){
		var gsjieshao=$('gsjianjiexx_2').value;
		var reg=/^[\D+\u4e00-\u9fa5]+$/g
		if (gsjieshao==""){
			$('show_pic9').className="no1";
			$('show_txt9').innerHTML="公司介绍不能为空";
			return false;
		}else{
			if (gsjieshao.length<20) {
				$('show_pic9').className="no1";
				$('show_txt9').innerHTML="字数在20-800内";
				return false;
			}else{
				$('show_pic9').className="yes1";
				$('show_txt9').innerHTML="非常好";
				return true;
			}
		}
	}

function checkForm3(){
	if (gsname()&&checkIpt()&&gsjieshao()) {
		$('FormError3').style.display='none';
		return true; 
	}else{
		console.log("公司信息出错");
		$('FormError3').style.display='block';
		return false;
	}
}
function checkForm(){
	if (checkForm1()&&checkForm2()&&checkForm3()){
		return true;
	}else{
		return false;
	}
}

var time9=10;
function showTiao(){
	if (checkForm()) {
		$('mask').style.display="block";
		$('show').style.display="block";
		document.body.style.overflow="visible";
		setInterval(daojishi,1000);
	}else{
		return false;
	}
}

function daojishi(){
	var str = time9+"秒";
		$('daoshu').innerHTML=str;
		time9--;
		if (time9==0) {
			window.location.href="login.html";
			return true;
		}
		console.log(time9);
}

